package com.example.stray_animal_management_system.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.stray_animal_management_system.entity.MessageBoard;
import com.example.stray_animal_management_system.mapper.MessageBoardMapper;
import com.example.stray_animal_management_system.service.MessageBoardService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: panpan
 * @time: 2025/11/2
 */
@Service
public class MessageBoardServiceImpl extends ServiceImpl<MessageBoardMapper, MessageBoard>
        implements MessageBoardService {

    @Override
    public List<MessageBoard> searchByKeyword(String keyword) {
        return this.list(new LambdaQueryWrapper<MessageBoard>()
                .like(MessageBoard::getContent, keyword)
                .orderByDesc(MessageBoard::getCreateTime));
    }

    @Override
    public List<MessageBoard> getByUserId(Integer userId) {
        return this.list(new LambdaQueryWrapper<MessageBoard>()
                .eq(MessageBoard::getUserId, userId)
                .orderByDesc(MessageBoard::getCreateTime));
    }
}